package team.xstudio.bedwarstoolkit.misc

import net.minecraft.nbt.CompoundTag
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
import net.minecraft.world.level.ItemLike

/**
 * Created in 2025/6/10
 * Project: bedwarstoolkit
 *
 * @author <a href="https://github.com/Bread-Nicecat">Bread_NiceCat</a>
 * <p>
 *
 * <p>
 **/
object BWItems {


    fun tnt() = withTag(Items.TNT)
    fun fireball() = withTag(Items.FIRE_CHARGE)

    private fun withTag(item: ItemLike, action: (CompoundTag) -> Unit = {}): ItemStack {
        return withTag(item.asItem().defaultInstance, action)
    }

    private fun withTag(itemStack: ItemStack, action: (CompoundTag) -> Unit = {}): ItemStack {
        val data = CompoundTag().also(action)
        itemStack.orCreateTag.put("bwt_data", data)
        return itemStack
    }

}